package com.imooc.bilibili.controller;

import com.imooc.bilibili.result.Result;
import com.imooc.bilibili.service.UserAuthService;
import com.imooc.bilibili.support.UserSupport;
import com.imooc.bilibili.vo.UserAuthorities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user_auth")
public class UserAuthController {

    @Autowired
    private UserSupport userSupport;

    @Autowired
    private UserAuthService userAuthService;

    @GetMapping("/user_authorities")
    public Result<UserAuthorities> getUserAuthorities() {
        Long userId = userSupport.getCurrnetUserId().get("userId");
        UserAuthorities userAuthorities = userAuthService.getUserAuthoritiesService(userId);
        return new Result<>(userAuthorities);
    }
}
